{
  LW Render -- LightWave Rendering State

  Based on lwrender.h which is:
  Copyright 1999, NewTek, Inc.
}

{
  Copyright 2012, Jameel Halabi

  This unit is part of the BlaiseWave wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}


unit LW_Render;

{$mode objfpc}{$H+}

interface

uses
  LW_Envel  ,
  LW_Handler,
  LW_Meshes ,
  LW_Types  ;

const
  LWITEM_NULL = PLWItem(0);

  // LWItemType
  LWI_OBJECT = 0;
  LWI_LIGHT  = 1;
  LWI_CAMERA = 2;
  LWI_BONE   = 3;

  // LWItemParam
  LWIP_POSITION   =  1;
  LWIP_RIGHT      =  2;
  LWIP_UP         =  3;
  LWIP_FORWARD    =  4;
  LWIP_ROTATION   =  5;
  LWIP_SCALING    =  6;
  LWIP_PIVOT      =  7;
  LWIP_W_POSITION =  8;
  LWIP_W_RIGHT    =  9;
  LWIP_W_UP       = 10;
  LWIP_W_FORWARD  = 11;
  LWIP_PIVOT_ROT  = 12;

  RTMODE_DISTANCE        = 0;
  RTMODE_REFLECTION      = 1;
  RTMODE_REFRACTION      = 2;
  RTMODE_DISSOLVE        = 3;
  RTMODE_SHADOW          = 4;
  RTMODE_OCCLUSION       = 5;
  RTMODE_BACKDROP        = 6;
  RTMODE_OCCLUSION_DEPTH = 7;
  RTMODE_MASK            = $000000FF;

  RTFLAG_CAMERA     = $04000000;
  RTFLAG_BACKSHADE  = $08000000;
  RTFLAG_BACKDROP   = $10000000;
  RTFLAG_OBJECT     = $20000000;
  RTFLAG_SAMPLEDRAY = $40000000;
  RTFLAG_NOPOLYGON  = $80000000;

  LWRT_SHADOW           = 1 shl 0; // This flag is on if the incoming ray is a shadow ray
  LWRT_PREVIEW          = 1 shl 1; // This flag is on if the spot is being rendered in a preview context, like the Viper.
  LWRT_POLYSIDE         = 1 shl 2; // This flag is on if the incoming ray hit the back side of the polygon
  LWRT_SAMPLEDRAY       = 1 shl 3; // This flag is on if the incoming ray was cast for sampling soft reflections, etc.
  LWRT_PREPROCESS       = 1 shl 4; // This flag is on if the incoming ray is a radiosity preprocess ray.
  LWRT_EXITING          = 1 shl 5; // This flag is on if the ray is going to exit to an undefined surface - Ie. vacuum/air, which needs to be handled by the material/shader.
  LWRT_DOUBLESIDED      = 1 shl 6; // This flag is on if the surface is double sided.
  LWRT_FRAME_PREPROCESS = 1 shl 7; // This flag is on if the incoming ray is a frame preprocess ray.
  LWRT_RADIOSITY        = 1 shl 8; // This flag is on if the incoming ray is a radiosity ray.
  LWRT_CAMERA           = 1 shl 9; // This flag is on if the incoming ray is a camera ray.

  LWITEM_RADIOSITY = PLWItem($21000000);
  LWITEM_CAUSTICS  = PLWItem($22000000);

  LWITEM_ALL = PLWItem(not 0);

  LWINIT_PREVIEW = 0;
  LWINIT_RENDER  = 1;

  LWLISTINFO_GLOBAL = 'LW List Info';

  SPLICE_HEAD = PLWItem(0);
  SPLICE_TAIL = PLWItem($ffffffff);

  LI_Failed                = -1; // returned only by index()
  LI_Success               =  0;
  LI_InvalidItemType       =  1;
  LI_ItemTypeMismatch      =  2;
  LI_InvalidPair           =  3;
  LI_InvalidBoneParent     =  4;
  LI_OutOfBounds           =  5;
  LI_MixedTypes            =  6;
  LI_MixedBones            =  7;
  LI_InvalidInsertionPoint =  8;
  LI_CyclicInsertionPoint  =  9;

  LWITEMINFO_GLOBAL = 'LW Item Info 6';

  LWVECF_0 = 1 shl 0;
  LWVECF_1 = 1 shl 1;
  LWVECF_2 = 1 shl 2;

  LWSRVF_DISABLED = 1 shl 0;
  LWSRVF_HIDDEN   = 1 shl 1;

  LWMOTCTL_KEYFRAMES         = 0;
  LWMOTCTL_TARGETING         = 1;
  LWMOTCTL_ALIGN_TO_VELOCITY = 2;
  LWMOTCTL_IK                = 3;
  LWMOTCTL_ALIGN_TO_PATH     = 4;
  LWMOTCTL_POLE              = 5;
  LWMOTCTL_SAMEITEM          = 6;

  LWITEMF_ACTIVE          = 1 shl 0;
  LWITEMF_UNAFFECT_BY_IK  = 1 shl 1;
  LWITEMF_FULLTIME_IK     = 1 shl 2;
  LWITEMF_GOAL_ORIENT     = 1 shl 3;
  LWITEMF_REACH_GOAL      = 1 shl 4;
  LWITEMF_USE_IKCHAINVALS = 1 shl 5;

  LWMOTGOAL_POSITION  = 0;
  LWMOTGOAL_POINT     = 1;
  LWMOTGOAL_ONYZPLANE = 2;

  LWMOTIK_INIT_FIRSTKEY      = 0;
  LWMOTIK_INIT_MOSTRECENTKEY = 1;
  LWMOTIK_INIT_CURRENTCHAN   = 2;
  LWMOTIK_INIT_CUSTOMFRAME   = 3;

  LWMOTIK_SOFT_OFF         = 0;
  LWMOTIK_SOFT_EXPONENTIAL = 1;
  LWMOTIK_SOFT_LINEAR      = 2;
  LWMOTIK_SOFT_CLAMP       = 3;

  LWMOTIK_SOFT_CHAINCHORD     = 0;
  LWMOTIK_SOFT_CHAINLENGTH    = 1;
  LWMOTIK_SOFT_CUSTOMDISTANCE = 2;

  LWMOTCTL_SAMEITEM_INTERPOLATE = 0;
  LWMOTCTL_SAMEITEM_COMPENSATE  = 1;
  LWMOTCTL_SAMEITEM_WORLD       = 1 shl 7;

  LWOBJECTINFO_GLOBAL = 'LW Object Info 9';

  LWOSHAD_SELF        = 1 shl 0;
  LWOSHAD_CAST        = 1 shl 1;
  LWOSHAD_RECEIVE     = 1 shl 2;

  LWOBJF_UNSEEN_BY_CAMERA       = 1 shl  0;
  LWOBJF_UNSEEN_BY_RAYS         = 1 shl  1;
  LWOBJF_UNAFFECT_BY_FOG        = 1 shl  2;
  LWOBJF_MORPH_MTSE             = 1 shl  3;
  LWOBJF_MORPH_SURFACES         = 1 shl  4;
  LWOBJF_MATTE                  = 1 shl  5;
  LWOBJF_UNSEEN_BY_ALPHA        = 1 shl  6; // This is set when object alpha is set to 'Unaffected By Object'
  LWOBJF_ALPHA_CONSTANT_BLACK   = 1 shl  7; // This is set when object alpha is set to 'Constant Black'
  LWOBJF_DISTANCEDISSOLVE       = 1 shl  8; // Added in version 6
  LWOBJF_BUMPENABLE             = 1 shl  9; // Added in version 6
  LWOBJF_FASTERBONES            = 1 shl 10; // Added in version 6
  LWOBJF_USEMORPHEDPOSITIONS    = 1 shl 11; // Added in version 6
  LWOBJF_CONTAINS1POINTPOLYGONS = 1 shl 12; // Added in version 6
  LWOBJF_CONTAINSPATCHES        = 1 shl 13; // Added in version 6
  LWOBJF_CONTAINSMETABALLS      = 1 shl 14; // Added in version 6
  LWOBJF_CONTAINSPARTIGONS      = 1 shl 15; // Added in version 6
  LWOBJF_CONTAINSCUSTOMPOLYGONS = 1 shl 16; // Added in version 6
  LWOBJF_NODEDISPENABLED        = 1 shl 17; // Added in version 7
  LWOBJF_NODEFORMERSAPPLIED     = 1 shl 18; // Added in version 7
  LWOBJF_UNSEEN_BY_RADIOSITY    = 1 shl 19;

  LWEDGEF_SILHOUETTE  = 1 shl 0;
  LWEDGEF_UNSHARED    = 1 shl 1;
  LWEDGEF_CREASE      = 1 shl 2;
  LWEDGEF_SURFACE     = 1 shl 3;
  LWEDGEF_OTHER       = 1 shl 4;
  LWEDGEF_SHRINK_DIST = 1 shl 8;

  LWTHICK_SILHOUETTE    = 0;
  LWTHICK_UNSHARED      = 1;
  LWTHICK_CREASE        = 2;
  LWTHICK_SURFACE       = 3;
  LWTHICK_OTHER         = 4;
  LWTHICK_LINE          = 5;
  LWTHICK_PARTICLE_HEAD = 6;
  LWTHICK_PARTICLE_TAIL = 7;

  LWBONEINFO_GLOBAL = 'LW Bone Info 5';

  LWBONEF_ACTIVE           = 1 shl  0;
  LWBONEF_LIMITED_RANGE    = 1 shl  1;
  LWBONEF_SCALE_STRENGTH   = 1 shl  2;
  LWBONEF_WEIGHT_MAP_ONLY  = 1 shl  3;
  LWBONEF_WEIGHT_NORM      = 1 shl  4;
  LWBONEF_JOINT_COMP       = 1 shl  5;
  LWBONEF_JOINT_COMP_PAR   = 1 shl  6;
  LWBONEF_MUSCLE_FLEX      = 1 shl  7;
  LWBONEF_MUSCLE_FLEX_PAR  = 1 shl  8;
  LWBONEF_TWIST            = 1 shl  9;
  LWBONEF_MUSCLE_BULGE     = 1 shl 10;
  LWBONEF_MUSCLE_BULGE_PAR = 1 shl 11;

  LWBONETYPE_ZAXIS   = 0;
  LWBONETYPE_JOINT   = 1;

  LWBONETRANS_REST   = 0;
  LWBONETRANS_FINAL  = 1;

  LWBONETRANS_OBJECT = 0;
  LWBONETRANS_PARENT = 1;
  LWBONETRANS_WORLD  = 2;

  LWLIGHTINFO_GLOBAL = 'LW Light Info 5';

  LWLIGHT_DISTANT = 0;
  LWLIGHT_POINT   = 1;
  LWLIGHT_SPOT    = 2;
  LWLIGHT_LINEAR  = 3;
  LWLIGHT_AREA    = 4;
  LWLIGHT_CUSTOM  = 100;

  LWLSHAD_OFF      = 0;
  LWLSHAD_RAYTRACE = 1;
  LWLSHAD_MAP      = 2;

  LWLFL_LIMITED_RANGE  = 1 shl 0;
  LWLFL_NO_DIFFUSE     = 1 shl 1;
  LWLFL_NO_SPECULAR    = 1 shl 2;
  LWLFL_NO_CAUSTICS    = 1 shl 3;
  LWLFL_LENS_FLARE     = 1 shl 4;
  LWLFL_VOLUMETRIC     = 1 shl 5;
  LWLFL_NO_OPENGL      = 1 shl 6;
  LWLFL_FIT_CONE       = 1 shl 7;
  LWLFL_CACHE_SHAD_MAP = 1 shl 8;

  LWLFALL_OFF        = 0;
  LWLFALL_LINEAR     = 1;
  LWLFALL_INV_DIST   = 2;
  LWLFALL_INV_DIST_2 = 3;


  LWCAMERAINFO_GLOBAL = 'LW Camera Info 6';

  LWCAMF_STEREO          = 1 shl  0;
  LWCAMF_LIMITED_REGION  = 1 shl  1; // This indicates that some form of limited region is enabled
  LWCAMF_MASK            = 1 shl  2; // defunct
  LWCAMF_DOF             = 1 shl  3;
  LWCAMF_PARTICLE_BLUR   = 1 shl  4;
  LWCAMF_LR_NOBORDERS    = 1 shl  5; // This indicates that limited region is being used without borders when limited region is enabled
  LWCAMF_FIELD           = 1 shl  6; // In Field Rendering, This Indicates Which Field Is Being Processed.
  LWCAMF_USECAMTYPE      = 1 shl  7; // Indicates that the camera uses a non-classical camera type. = rev.4+;
  LWCAMF_SUPPORTS_DOF    = 1 shl  8; // Indicates that the camera supports Depth Of Field rendering
  LWCAMF_EYE             = 1 shl  9; // In Stereo Rendering, This Indicates Which Eye Is Being Processed.
  LWCAMF_SUPPORTS_STEREO = 1 shl 10; // Indicates that the camera supports stereo rendering

  LWCAMMB_OFF       = 0;
  LWCAMMB_NORMAL    = 1;
  LWCAMMB_DITHERED  = 2;
  LWCAMMB_PHOTOREAL = 3;

  LWCAMFIELDR_OFF       = 0;
  LWCAMFIELDR_EVENFIRST = 1;
  LWCAMFIELDR_ODDFIRST  = 2;

  LWCAMERAEVALUATIONFUNCS_GLOBAL = 'LW Camera Evaluation Funcs 2';

  // For use with LWSceneInfo->loadInProgress
  SI_NoLoad        = 0;
  SI_LoadScene     = 1;
  SI_LoadFromScene = 2;

  LWRT_BackDrop    = 0; // Throws rays in a random distribution, if a miss, used backdrop color.
  LWRT_MonteCarlo  = 1; // Throws rays in a random distribution.
  LWRT_FinalGather = 2; // Final Gather implementation.
  LWRT_Sizeof      = 3;

  // LWRENDERINGMODE
  lwrm_None           = 0; // not currently rendering.
  lwrm_SceneBake      = 1; // a scene frame baking.
  lwrm_Scene          = 2; // a scene.
  lwrm_FrameBake      = 3; // a single frame baking.
  lwrm_Frame          = 4; // a single frame.
  lwrm_Inspire        = 5; // a scene but with dimensions greater than 800 x 600 for Inspire.
  lwrm_SelectedObject = 6; // selected objects only.
  lwrm_sizeof         = 7;

  // Stereoscopic eyes.

  // LWCameraEye
  LWCAMEYE_CENTER = 0; // Stereoscopic center eye.
  LWCAMEYE_LEFT   = 1; // Stereoscopic left eye.
  LWCAMEYE_RIGHT  = 2; // Stereoscopic right eye.
  LWCAMEYE_sizeof = 3;

  // LWAnimPass
  LWANIMPASS_MAIN        = 0;
  LWANIMPASS_PRELIMINARY = 1;
  LWANIMPASS_BLUR        = 2;
  LWANIMPASS_RESTORE     = 3;

  LWSCENEINFO_GLOBAL = 'LW Scene Info 9';

  // SceneInfo.renderType
  LWRTYPE_WIRE      = 0;
  LWRTYPE_QUICK     = 1;
  LWRTYPE_REALISTIC = 2;

  // SceneInfo.renderOpts
  LWROPT_SHADOWTRACE          = 1 shl  0;
  LWROPT_REFLECTTRACE         = 1 shl  1;
  LWROPT_REFRACTTRACE         = 1 shl  2;
  LWROPT_FIELDS               = 1 shl  3;
  LWROPT_EVENFIELDS           = 1 shl  4;
  LWROPT_MOTIONBLUR           = 1 shl  5;
  LWROPT_DEPTHOFFIELD         = 1 shl  6;
  LWROPT_LIMITEDREGION        = 1 shl  7;
  LWROPT_PARTICLEBLUR         = 1 shl  8;
  LWROPT_ENHANCEDAA           = 1 shl  9;
  LWROPT_SAVEANIM             = 1 shl 10;
  LWROPT_SAVERGB              = 1 shl 11;
  LWROPT_SAVEALPHA            = 1 shl 12;
  LWROPT_ZBUFFERAA            = 1 shl 13; // added 12/29/2004
  LWROPT_RTTRANSPARENCIES     = 1 shl 14; // added 11/01/2006
  LWROPT_RADIOSITY            = 1 shl 15;
  LWROPT_CAUSTICS             = 1 shl 16;
  LWROPT_OCCLUSION            = 1 shl 17;
  LWROPT_RENDERLINES          = 1 shl 18;
  LWROPT_INTERPOLATED         = 1 shl 19;
  LWROPT_BLURBACKGROUND       = 1 shl 20;
  LWROPT_USETRANSPARENCY      = 1 shl 21;
  LWROPT_VOLUMETRICRADIOSITY  = 1 shl 22;
  LWROPT_USEAMBIENT           = 1 shl 23;
  LWROPT_DIRECTIONALRAYS      = 1 shl 24;
  LWROPT_LIMITDYNAMICRANGE    = 1 shl 25;
  LWROPT_CACHERADIOSITY       = 1 shl 26;
  LWROPT_USEGRADIENTS         = 1 shl 27;
  LWROPT_USEBEHINDTEST        = 1 shl 28;
  LWROPT_CAUSTICSCACHE        = 1 shl 29;
  LWROPT_EYECAMERA            = 1 shl 30;
  LWROPT_UNPREMULTIPLIEDALPHA = 1 shl 31;

  // SceneInfo.radiosityFlags
  LWRDFLG_SHOW_NODES                      = 1 shl  0;
  LWRDFLG_SHOW_CELLS                      = 1 shl  1;
  LWRDFLG_SHOW_COLOR_CELLS                = 1 shl  2;
  LWRDFLG_SHOW_SAMPLES                    = 1 shl  3;
  LWRDFLG_SHOW_MISSING_PREPROCESS_SAMPLES = 1 shl  4;
  LWRDFLG_SHOW_MISSING_RENDER_SAMPLES     = 1 shl  5;
  LWRDFLG_SHOW_SECOND_BOUNCE              = 1 shl  6;
  LWRDFLG_SHOW_BEHIND                     = 1 shl  7;
  LWRDFLG_USE_BUMPS                       = 1 shl 31;

  LWTIMEINFO_GLOBAL     = 'LW Time Info';

  LWCOMPINFO_GLOBAL     = 'LW Compositing Info';

  LWBACKDROPINFO_GLOBAL = 'LW Backdrop Info 2';

  LWBACK_SOLID    = 0;
  LWBACK_GRADIENT = 1;

  LWFOGINFO_GLOBAL   = 'LW Fog Info';

  LWFOG_NONE       = 0;
  LWFOG_LINEAR     = 1;
  LWFOG_NONLINEAR1 = 2;
  LWFOG_NONLINEAR2 = 3;
  LWFOG_REALISTIC  = 4;

  LWFOGF_BACKGROUND = 1 shl 0;

  LWINTERFACEINFO_GLOBAL = 'LW Interface Info 7';

  LWITEMF_SELECTED     = 1 shl 0;
  LWITEMF_SHOWCHILDREN = 1 shl 1;
  LWITEMF_SHOWCHANNELS = 1 shl 2;
  LWITEMF_LOCKED       = 1 shl 3;

  LWDYNUP_OFF         = 0;
  LWDYNUP_DELAYED     = 1;
  LWDYNUP_INTERACTIVE = 2;

  LWIVIS_HIDDEN  = 0;
  LWIVIS_VISIBLE = 1;

  LWOVIS_HIDDEN        = 0;
  LWOVIS_BOUNDINGBOX   = 1;
  LWOVIS_VERTICES      = 2;
  LWOVIS_WIREFRAME     = 3;
  LWOVIS_FFWIREFRAME   = 4;
  LWOVIS_SHADED        = 5;
  LWOVIS_TEXTURED      = 6;
  LWOVIS_TEXTURED_WIRE = 7;
  LWOVIS_VIEWPORTOBJ   = 8;

  LWAKC_OFF      = 0;
  LWAKC_MODIFIED = 1;
  LWAKC_ALL      = 2;

  LWDISPF_MOTIONPATHS = 1 shl 0;
  LWDISPF_HANDLES     = 1 shl 1;
  LWDISPF_IKCHAINS    = 1 shl 2;
  LWDISPF_CAGES       = 1 shl 3;
  LWDISPF_SAFEAREAS   = 1 shl 4;
  LWDISPF_FIELDCHART  = 1 shl 5;

  LWGENF_HIDETOOLBAR         = 1 shl  0;
  LWGENF_RIGHTTOOLBAR        = 1 shl  1;
  LWGENF_PARENTINPLACE       = 1 shl  2;
  LWGENF_FRACTIONALFRAME     = 1 shl  3;
  LWGENF_KEYSINSLIDER        = 1 shl  4;
  LWGENF_PLAYEXACTRATE       = 1 shl  5;
  LWGENF_AUTOKEY             = 1 shl  6;
  LWGENF_IKENABLE            = 1 shl  7;
  LWGENF_LMBITEMSELECT       = 1 shl  8;
  LWGENF_AUTOCONF            = 1 shl  9;
  LWGENF_DOUBLECLICKBONEMODE = 1 shl 10;
  LWGENF_MCENABLE            = 1 shl 11;

  LWALERT_BEGINNER     = 0;
  LWALERT_INTERMEDIATE = 1;
  LWALERT_EXPERT       = 2;

  LWITEMCOL_CURRENT  = 0;
  LWITEMCOL_NORMAL   = 1;
  LWITEMCOL_SELECTED = 2;

  LWVIEWPORTINFO_GLOBAL = 'LW Viewport Info 5';

  LVVIEWT_NONE        =  0;
  LVVIEWT_TOP         =  1;
  LVVIEWT_BOTTOM      =  2;
  LVVIEWT_BACK        =  3;
  LVVIEWT_FRONT       =  4;
  LVVIEWT_RIGHT       =  5;
  LVVIEWT_LEFT        =  6;
  LVVIEWT_PERSPECTIVE =  7;
  LVVIEWT_LIGHT       =  8;
  LVVIEWT_CAMERA      =  9;
  LVVIEWT_SCHEMATIC   = 10;

  LWVIEWF_CENTER      = 1 shl 0;
  LWVIEWF_WEIGHTSHADE = 1 shl 1;
  LWVIEWF_XRAY        = 1 shl 2;
  LWVIEWF_HEADLIGHT   = 1 shl 3;

  LWGLOBALPOOL_RENDER_GLOBAL = 'Global Render Memory';
  LWGLOBALPOOL_GLOBAL        = 'Global Memory';

type
  PLWShaderAccess = ^TLWShaderAccess;
  TLWShaderAccess = record end;

  TLWItemType  = Integer;
  TLWItemParam = Integer;

  PLWItemInstancer = Pointer;
  PLWRenderData    = Pointer;

  TLWRayCastFunc = function
                   (const Position  : TLWDVector;
                    const Direction : TLWDVector) : Double;

  TLWRayTraceFunc = function
                    (const Position  : TLWDVector;
                     const Direction : TLWDVector;
                           Color     : TLWDVector) : Double;

  TLWRayShadeFunc = function
                    (const Position     : TLWDVector     ;
                     const Direction    : TLWDVector     ;
                           ShaderAccess : PLWShaderAccess) : Double;

  TLWIlluminateFunc = function
                      (      Light     : PLWItem   ;
                       const Position  : TLWDVector;
                             Direction : TLWDVector;
                             Color     : TLWDVector) : Integer;

  TLWIlluminateNormalFunc = function
                            (      Light     : PLWItem      ;
                                   RD        : PLWRenderData;
                             const Position  : TLWDVector   ;
                                   Direction : TLWDVector   ;
                             const NormalVec : TLWDVector   ;
                                   Color     : TLWDVector   ) : Integer;

  TLightSampleFunc = function
                     (      Data  : Pointer    ;
                            Light : PLWItem    ;
                      const Dir   : TLWDVector ;
                      const Color : TLWDVector4) : Integer;

  TLWIlluminateSampleFunc = function
                            (      Light   : PLWItem         ;
                             const Pos     : TLWDVector      ;
                                   Dir     : TLWDVector      ;
                                   Sampler : TLightSampleFunc;
                                   Data    : Pointer         ) : Double;

  TLWIlluminateSampleNormalFunc = function
                                  (      Light     : PLWItem         ;
                                         RD        : PLWRenderData   ;
                                   const Pos       : TLWDVector      ;
                                   const NormalVec : TLWDVector      ;
                                         Sampler   : TLightSampleFunc;
                                         Data      : Pointer          ) : Double;

  TLWBufferGetValFunc = procedure
                        (RD     : PLWRenderData;
                         Type_  : Integer      ;
                         Num    : Integer      ;
                         Buffer : PDouble      ) ;
  TLWBufferSetValFunc = procedure
                        (RD     : PLWRenderData;
                         Type_  : Integer      ;
                         Num    : Integer      ;
                         Buffer : PDouble      ) ;

  TLWRayTraceModeFunc = function
                        (const Position  : TLWDVector;
                         const Direction : TLWDVector;
                               Color     : TLWDVector;
                         const ETA       : Double    ;
                         const RTMode    : Integer   ) : Double;

  PLWRayData = Pointer;

  PLWRayTraceData = ^TLWRayTraceData;
  TLWRayTraceData = record
    // send
    RayStart : TLWDVector;
    RayDir   : TLWDVector;
    Backdrop : TLWDVector; // Fill this if RTFLAG_BACKDROP is set.
    Weight   : TLWDVector; // This color is used the weigh the contribution weight of the ray in the renderer.
    ETA      : Double    ;
    Flags    : Integer   ;

    // receive
    Ray      : PLWRayData; // This data needs to be filled by TLWRayTraceData before calling LWRayTraceShade.
    Len      : Double    ;
    Result   : TLWDVector; // The result is filled with the backdrop color at TLWRayTraceData if the ray doesn't hit anything.
  end;

  TLWRayTraceDataFunc = procedure
                        (RenderData    : PLWRenderData  ;
                         RayTraceData  : PLWRayTraceData) ;
  TLWRayTraceShadeFunc = procedure
                         (RayTraceData : PLWRayTraceData) ;

  PRandomFloatData  = Pointer;

  TLWRandomFloatFunc = function
                       (RandomFloatData : PRandomFloatData) : Single;

  PLWSamplerState = Pointer;

  TLWGetSamplerRangeFunc = function
                           (SamplerState : PLWSamplerState;
                            Start        : PCardinal      ;
                            End_         : PCardinal      ) : Single;
  TLWGetSample2DFunc = procedure
                       (SamplerState : PLWSamplerState;
                        Index        : UInt32         ;
                        Sample       : PSingle        ) ; // PSingle must point to 2 floats.
  TLWGetSample1DFunc = function
                       (SamplerState : PLWSamplerState;
                        Index        : UInt32         ) : Single;

  {
    Animation item handler extensions.
  }

  PLWNameChangeData = ^TLWNameChangeData;
  TLWNameChangeData = record
    OldName : PChar  ;
    NewName : PChar  ;
    ID      : PLWItem;
  end;

  PLWItemFuncs = ^TLWItemFuncs;
  TLWItemFuncs = record
    UseItems:   function
                (      Instance       : PLWInstance      ) : PPLWItem;
    ChangeID:   procedure
                (      Instance       : PLWInstance      ;
                 const IDList         : PPLWItem         ) ;
    ChangeName: procedure
                (      Instance       : PLWInstance      ;
                 const NameChangeData : PLWNameChangeData) ;
  end;

  PLWItemHandler = ^TLWItemHandler;
  TLWItemHandler = record
    Inst : PLWInstanceFuncs;
    Item : PLWItemFuncs    ;
  end;

  {
    Render handler extensions.
  }

  PLWRenderFuncs = ^TLWRenderFuncs;
  TLWRenderFuncs = record
    Init:    function
             (Instance : PLWInstance;
              Mode     : Integer    ) : PLWError;
    Cleanup: procedure
             (Instance : PLWInstance) ;
    NewTime: function
             (Instance : PLWInstance;
              Frame    : TLWFrame   ;
              Time     : TLWTime    ) : PLWError;
  end;

  PLWRenderHandler = ^TLWRenderHandler;
  TLWRenderHandler = record
    Inst : PLWInstanceFuncs;
    Item : PLWItemFuncs    ;
    Rend : PLWRenderFuncs  ;
  end;

  {
    Globals.
  }

  PLWListInfo = ^TLWListInfo;
  TLWListInfo = record
    Index:   function
             (Object_ : PLWItem ) : Integer;
    Reorder: function
             (List    : PPLWItem) : Integer;
    Swap:    function
             (List    : PPLWItem) : Integer;
    Splice:  function
             (Point   : PLWItem ;
              List    : PPLWItem) : Integer;
  end;

  PLWItemInfo = ^TLWItemInfo;
  TLWItemInfo = record
    First               : function
             (      Itemtype     : TLWItemType                 ;
                    BoneObject   : PLWItem                     ) : PLWItem     ;
    Next                : function
             (      Item         : PLWItem                     ) : PLWItem     ;
    FirstChild          : function
             (      Parent       : PLWItem                     ) : PLWItem     ;
    NextChild           : function
             (      Parent       : PLWItem                     ;
                    PrevChild    : PLWItem                     ) : PLWItem     ;
    Parent              : function
             (      Item         : PLWItem                     ) : PLWItem     ;
    Target              : function
             (      Item         : PLWItem                     ) : PLWItem     ;
    Goal                : function
             (      Item         : PLWItem                     ) : PLWItem     ;
    Type_               : function
             (      Item         : PLWItem                     ) : TLWItemType ;
    Name                : function
             (      Item         : PLWItem                     ) : PChar       ;
    Param               : procedure
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ;
                    Time         : TLWTime                     ;
                    Vector       : TLWDVector                  ) ;
    Limits              : function
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ;
                    Min          : TLWDVector                  ;
                    Max          : TLWDVector                  ) : UInt32      ;
    GetTag              : function
             (      Item         : PLWItem                     ;
                    TagNum       : Integer                     ) : PChar       ;
    SetTag              : procedure
             (      Item         : PLWItem                     ;
                    TagNum       : Integer                     ;
                    Tag          : PChar                       ) ;
    ChanGroup           : function
             (      Item         : PLWItem                     ) : PLWChanGroup;
    Server              : function
             (      Item         : PLWItem                     ;
                    Class_       : PChar                       ;
                    Index        : Integer                     ) : PChar       ;
    ServerFlags         : function
             (      Item         : PLWItem                     ;
                    Class_       : PChar                       ;
                    Index        : Integer                     ) : UInt32      ;
    Controller          : procedure
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ;
                    Type_        : array {[0..2]} of Integer   ) ;
    Flags               : function
             (      Item         : PLWItem                     ) : UInt32      ;
    LookAhead           : function
             (      Item         : PLWItem                     ) : TLWTime     ;
    GoalStrength        : function
             (      Item         : PLWItem                     ;
                    Time         : TLWTime                     ) : Double      ;
    Stiffness           : procedure
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ;
                    Vector       : TLWDVector                  ) ;
    AxisLocks           : function
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ) : UInt32      ;
    MaxLookSteps        : function
             (      Item         : PLWItem                     ) : UInt32      ;
    ReliableDistance    : function
             (      Item         : PLWItem                     ) : Double      ;
    GoalObjective       : function
             (      Item         : PLWItem                     ) : UInt32      ;
    IKFKBlending        : function
             (      Item         : PLWItem                     ;
                    Time         : TLWTime                     ) : Double      ;
    IKInitialState      : function
             (      Item         : PLWItem                     ) : UInt32      ;
    IKInitialStateFrame : function
             (      Item         : PLWItem                     ;
                    Time         : TLWTime                     ) : TLWFrame    ;
    IKSoft              : function
             (      Item         : PLWItem                     ;
                    Time         : TLWTime                     ;
                    DistanceType : PUInt32                     ;
                    Min          : PDouble                     ;
                    Max          : PDouble                     ) : UInt32      ;
    Pole                : function
             (      Item         : PLWItem                     ) : PLWItem     ;
    SameItem            : function
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ) : PLWItem     ;
    SameItemBlend       : function
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ;
                    Time         : TLWTime                     ) : Double      ;
    SameItemBlendMethod : function
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ) : UInt32      ;
    SameItemFlags       : function
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ) : UInt32      ;
    Selected            : function
             (      Item         : PLWItem                     ) : UInt32      ;
    Follow              : procedure
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ;
                    Follow       : array {[0..2]} of Integer   ;
                    Txtr         : array {[0..2]} of PLWTexture) ;
    ControllerTrans     : procedure
             (      Item         : PLWItem                     ;
                    ParamType    : TLWItemParam                ;
                    Mul          : array {[0..2]} of Double    ;
                    Add          : array {[0..2]} of Double    ) ;
  end;

  PLWObjectInfo = ^TLWObjectInfo;
  TLWObjectInfo = record
    Filename                   : function
                             (      ObjectItem : PLWItem   ) : PChar           ;
    NumPoints                  : function
                             (      ObjectItem : PLWItem   ) : Integer         ;
    NumPolygons                : function
                             (      ObjectItem : PLWItem   ) : Integer         ;
    ShadowOpts                 : function
                             (      ObjectItem : PLWItem   ) : UInt32          ;
    Dissolve                   : function
                             (      ObjectItem : PLWItem   ;
                                    InTime     : TLWTime   ) : Double          ;
    MeshInfo                   : function
                             (      ObjectItem : PLWItem   ;
                                    FrozenFlag : Integer   ) : PLWMeshInfo     ;
    Flags                      : function
                             (      ObjectItem : PLWItem   ) : UInt32          ;
    Fog                        : function
                             (      ObjectItem : PLWItem   ;
                                    InTime     : TLWTime   ) : Double          ;
    DispMap                    : function
                             (      ObjectItem : PLWItem   ) : PLWTexture      ;
    ClipMap                    : function
                             (      ObjectItem : PLWItem   ) : PLWTexture      ;
    PatchLevel                 : procedure
                             (      ObjectItem : PLWItem   ;
                                    ForDisplay : PInteger  ;
                                    ForRender  : PInteger  ) ;
    MetaballRes                : procedure
                             (      ObjectItem : PLWItem   ;
                                    ForDisplay : PDouble   ;
                                    ForRender  : PDouble   ) ;
    BoneSource                 : function
                             (      ObjectItem : PLWItem   ) : PLWItem         ;
    MorphTarget                : function
                             (      ObjectItem : PLWItem   ) : PLWItem         ;
    MorphAmount                : function
                             (      ObjectItem : PLWItem   ;
                                    InTime     : TLWTime   ) : Double          ;
    EdgeOpts                   : function
                             (      ObjectItem : PLWItem   ) : UInt32          ;
    EdgeColor                  : procedure
                             (      ObjectItem : PLWItem   ;
                                    InTime     : TLWTime   ;
                                    Color      : TLWDVector) ;
    SubdivOrder                : function
                             (      ObjectItem : PLWItem   ) : Integer         ;
    PolygonSize                : function
                             (      ObjectItem : PLWItem   ;
                                    InTime     : TLWTime   ) : Double          ;
    Excluded                   : function
                             (      ObjectItem : PLWItem   ;
                                    LightItem  : PLWItem   ) : Integer         ;
    MatteColor                 : procedure
                             (      ObjectItem : PLWItem   ;
                                    InTime     : TLWTime   ;
                                    Color      : TLWDVector) ;
    Thickness                  : function
                             (      ObjectItem : PLWItem   ;
                                    InTime     : TLWTime   ;
                                    Type_      : Integer   ) : Double          ;
    EdgeZScale                 : function
                             (      ObjectItem : PLWItem   ;
                                    InTime     : TLWTime   ) : Double          ;
    // added for version 5: obtains nominal distance value used when shrink edges is enabled.
    ShrinkEdgesNominalDistance : function
                             (      ObjectItem : PLWItem   ;
                                    InTime     : TLWTime   ) : Double          ;
    // added for version 6
    MaxDissolveDistance        : function
                             (      ObjectItem : PLWItem   ) : Double          ;
    // added for version 6
    BumpDistance               : function
                             (      ObjectItem : PLWItem   ) : Double          ;
    // added for version 7
    GetGroupIndex              : function
                             (      ObjectItem : PLWItem   ) : UInt32          ;
    DispMapOrder               : function
                             (      ObjectItem : PLWItem   ) : Integer         ;
    BumpOrder                  : function
                             (      ObjectItem : PLWItem   ) : Integer         ;
    GetNodeEditor              : function
                             (      ObjectItem : PLWItem   ) : PNodeEditor     ;
    NodeOrder                  : function
                             (      ObjectItem : PLWItem   ) : Integer         ;
    // added for version 8
    Bounds                     : procedure
                             (      ObjectItem : PLWItem   ;
                                    Min        : TLWDVector;
                                    Max        : TLWDVector) ;
    ShadowOffsetDistance       : function
                             (      ObjectItem : PLWItem   ) : Double          ;
    // added for version 9
    Instancer                  : function
                             (      ObjectItem : PLWItem   ) : PLWItemInstancer;
  end;

  PLWBoneInfo = ^TLWBoneInfo;
  TLWBoneInfo = record
    Flags           : function
                      (      Bone     : PLWItem      ) : UInt32  ;
    RestParam       : procedure
                      (      Bone     : PLWItem      ;
                             ItemParam  : TLWItemParam  ;
                             Vector     : TLWDVector   ) ;
    RestLength      : function
                      (      Bone     : PLWItem      ) : Double  ;
    Limits          : procedure
                      (      Bone     : PLWItem      ;
                             Inner                     ,
                             Outer      : PDouble      ) ;
    WeightMap       : function
                      (      Bone     : PLWItem      ) : PChar   ; // const
    Strength        : function
                      (      Bone     : PLWItem      ) : Double  ;
    Falloff         : function
                      (      Bone     : PLWItem      ) : Integer ;
    JointComp       : procedure
                      (      Bone     : PLWItem      ;
                             Self                      ,
                             Parent     : PDouble      ) ;
    MuscleFlex      : procedure
                      (      Bone     : PLWItem      ;
                             Self                      ,
                             Parent     : PDouble      ) ;
    Type_           : function
                      (      Bone     : PLWItem      ) : Integer ;
    Twist           : function
                      (      Bone     : PLWItem      ) : Double  ;
    Transform       : function
                      (      Bone     : PLWItem      ;
                             Transform                 ,
                             RelativeTo : Integer      ;
                             M          : TLWFMatrix3  ;
                             Pos                       ,
                             End_       : TLWFVector   ) : Integer ;
    MuscleBulge     : procedure
                      (      Bone     : PLWItem      ;
                             Self                      ,
                             Parent     : PDouble      ) ;
    MuscleBulgeMap  : procedure
                      (      Bone     : PLWItem      ;
                             Self                      ,
                             Parent     : PLWTexture   ) ;
    DisplacementMap : procedure
                      (      Bone     : PLWItem      ;
                             Self                      ,
                             Parent     : PLWTexture   ) ;
  end;

  PLWLightInfo = ^TLWLightInfo;
  TLWLightInfo = record
      Ambient                  : procedure
                                 (      Time       : TLWTime      ;
                                        Color      : TLWDVector   );
      Type_                    : function
                                 (      ItemID     : PLWItem      ) : Integer    ;
      Color                    : procedure
                                 (      ItemID     : PLWItem      ;
                                        Time       : TLWTime      ;
                                        Color      : TLWDVector   ) ;
      ShadowType               : function
                                 (      ItemID     : PLWItem      ) : Integer    ;
      ConeAngles               : procedure
                                 (      ItemID     : PLWItem      ;
                                        Radius                    ,
                                        Edge       : PDouble      ) ;
      Flags                    : function
                                 (      ItemID     : PLWItem      ) : UInt32     ;

      Range                    : function
                                 (      ItemID     : PLWItem      ;
                                        Time       : TLWTime      ) : Double     ;
      Falloff                  : function
                                 (      ItemID     : PLWItem      ) : Integer     ;
      ProjImage                : function
                                 (      ItemID     : PLWItem      ) : PLWImage    ;
      ShadMapSize              : function
                                 (      ItemID     : PLWItem      ) : Integer     ;
      ShadMapAngle             : function
                                 (      ItemID     : PLWItem      ;
                                        Time       : TLWTime      ) : Double     ;
      ShadMapFuzz              : function
                                 (      ItemID     : PLWItem      ;
                                        Time       : TLWTime      ) : Double     ;
      Quality                  : function
                                 (      ItemID     : PLWItem      ;
                                        Time       : TLWTime      ) : Integer    ;
      RawColor                 : procedure
                                 (      ItemID     : PLWItem      ;
                                        Time       : TLWTime      ;
                                        Color      : TLWDVector   ) ;
      Intensity                : function
                                 (      ItemID     : PLWItem      ;
                                        Time       : TLWTime      ) : Double     ;
      ShadowColor              : procedure
                                 (      ItemID     : PLWItem      ;
                                        Time       : TLWTime      ;
                                        Color      : TLWDVector   ) ;
      AmbientIntensity         : function
                                 (      Time       : TLWTime      ) : Double     ;
      AmbientRaw               : procedure
                                 (      Time       : TLWTime      ;
                                        Color      : TLWDVector   ) ;
  end;

  PLWCameraRay = ^TLWCameraRay;
  TLWCameraRay = record
    rayPos   : TLWDVector ;
    rayDir   : TLWDVector ;
    filmNorm : TLWDVector ;
    filter   : Array[0..2] of TLWDVector;
  end;

  PLWFrameInfo = ^TLWFrameInfo;
  TLWFrameInfo = record
    frame           : TLWFrame ;
    start           : TLWTime  ;
    duration        : TLWTime  ;
    framesPerSecond : Double   ;
    motionSteps     : UInt32   ;
  end;

  PLWComponentTimingInfo = ^TLWComponentTimingInfo;
  TLWComponentTimingInfo  = record
    Count           : UInt32   ;
    Offset                     ,
    Duration                   ,
    Stride          : Double   ;
  end;

  PLWFrameTimingInfo = ^TLWFrameTimingInfo;
  TLWFrameTimingInfo = record
      frame     : TLWComponentTimingInfo ;
      fields    : TLWComponentTimingInfo ;
      steps     : TLWComponentTimingInfo ;
      scanlines : TLWComponentTimingInfo ;
      pixels    : TLWComponentTimingInfo ;
  end;

  PLWCameraInfo = ^TLWCameraInfo;
  TLWCameraInfo = record
    ZoomFactor                : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double  ;
    FocalLength               : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double  ;
    FocalDistance             : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double  ;
    FStop                     : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double  ;
    BlurLength                : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double  ;
    FovAngles                 : procedure
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ;
                                        Horizontal               ,
                                        Vertical   : PDouble     )           ;
    Flags                     : function
                                (       ItemID     : PLWItem     ) : UInt32  ;
    Resolution                : procedure
                                (       ItemID     : PLWItem     ;
                                        Width                    ,
                                        Height     : PInteger    )           ;
    PixelAspect               : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double  ;
    Separation                : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double  ;
    RegionLimits              : procedure
                                (       ItemID     : PLWItem     ;
                                        Out_x0                   ,
                                        Out_y0                   ,
                                        Out_x1                   ,
                                        Out_y1     : PInteger    ) ;

    { Defunct}
    MaskLimits                : procedure
                                (       ItemID     : PLWItem     ;
                                        Out_x0                   ,
                                        Out_y0                   ,
                                        Out_x1                   ,
                                        Out_y1     : PInteger    ) ;
    { Defunct}
    MaskColor                 : procedure
                                (       ItemID     : PLWItem     ;
                                        Color      : TLWDVector  ) ;

    { Added for version 3:
      Retrieve motion blur setting for a camera item, 1=normal, 2=dither }
    MotionBlur                : function
                                (       ItemID     : PLWItem     ) : UInt32  ;
    { Added for version 3:
      Retrieve field rendering state }
    FieldRendering            : function
                                (       ItemID     : PLWItem     ) : UInt32  ;
    IrisPos                   : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ;
                                        Pass       : Integer     ;
                                        IX                       ,
                                        IY         : PSingle     ) : Integer ;

    { Defunct}
    UsingGlobalResolution     : function
                                (       ItemID     : PLWItem     ) : Integer ;
    { Defunct}
    UsingGlobalBlur           : function
                                (       ItemID     : PLWItem     ) : Integer ;
    { Defunct}
    UsingGlobalMask           : function
                                (       ItemID     : PLWItem     ) : Integer ;
    MotionBlurPasses          : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : UInt32 ;
    ShutterEfficiency         : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double ;
    NoiseSampler              : function
                                (       ItemID     : PLWItem     ) : UINt32  ;
    FilmSize                  : procedure
                                (        ItemID    : PLWItem     ;
                                         Width                   ,
                                         Height    : PDouble     ) ;
    FrameTiming               : function
                                (       ItemID     : PLWItem     ;
                                        Frame      : TLWFrame    ;
                                        TimingInfo : PLWFrameTimingInfo ) : UInt32 ;
    AntiAliasing              : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : UInt32 ;
    OverSampling              : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double ;
    Diaphragm                 : procedure
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ;
                                        Sides      : PInteger    ;
                                        Rotation   : PDouble     ) ;
    ConvergencePoInteger      : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double ;
    UsingConvergencePoInteger : function
                                (       ItemID     : PLWItem     ) : Integer ;
    ConvergenceToeIn          : function
                                (       ItemID     : PLWItem     ;
                                        Time       : TLWTime     ) : Double ;
  end;

  PLWCameraEvaluator = Pointer;

  PLWCameraEvaluationFuncs = ^TLWCameraEvaluationFuncs;
  TLWCameraEvaluationFuncs = record
    Create    : function
                (       Camera       : PLWItem            ) : PLWCameraEvaluator ;
    Destroy   : procedure
                (       CamEvaluator : PLWCameraEvaluator ) ;
    Init      : function
                (       CamEvaluator : PLWCameraEvaluator ;
                        Mode         : Integer            ) : PLWError           ;
    CleanUp   : procedure
                (       CamEvaluator : PLWCameraEvaluator ) ;
    NewTime   : function
                (       CamEvaluator : PLWCameraEvaluator ;
                        Frame        : TLWFrame           ;
                        InTime       : TLWTime            ) : PLWError           ;
    Preview   : function
                (       CamEvaluator : PLWCameraEvaluator ;
                        LPX                               ,
                        LPY          : Double             ;
                        Projection   : TLWDMatrix4        ) : Integer            ;

    NewFrame  : function
                (       CamEvaluator : PLWCameraEvaluator ) : PLWError           ;
    Evaluate  : function
                (       CamEvaluator : PLWCameraEvaluator ;
                        FPX                               ,
                        FPY                               ,
                        LPX                               ,
                        LPY                               ,
                        FracTime     : Double             ;
                        CamRay       : TLWCameraRay       ) : Integer            ;
  end;

  PLWSceneInfo = ^TLWSceneInfo;
  TLWSceneInfo = record
    Name               : PChar    ; // const
    Filename           : PChar    ; // const
    NumPoints                     ,
    NumPolygons                   ,
    RenderType                    ,
    RenderOpts         : Integer  ;
    FrameStart         : TLWFrame ;
    FrameEnd           : TLWFrame ;
    FrameStep          : TLWFrame ;
    FramesPerSecond    : Double   ;
    FrameWidth                    ,
    FrameHeight        : Integer  ;
    PixelAspect        : Double   ;
    MinSamplesPerPixel            ,
    MaxSamplesPerPixel : Integer  ;
    LimitedRegion      : Array[0..3] of Integer; { x0, y0, x1, y1}
    RecursionDepth     : Integer  ;
    RenderCamera       : function
                         (       Time   : TLWTime ) : PLWItem ;
    NumThreads         : Integer  ;
    AnimFilename       : Pchar    ; // const
    RGBPrefix          : Pchar    ; // const
    AlphaPrefix        : Pchar    ; // const
    { Added for version 4:
        Current antialiasing setting 0=off, 1-lowest,
        increasing for higher values (currently up to 4=extreme)
      Added 12/29/2004  :
        100 to 114; use PLD (with level 1 being 100 and level 15 being 114) }
    Antialiasing       : Integer  ;
    { Added for version 4:
        1=enabled, 0=disabled. Only valid when antialiasing is 1 thru 4 }
    EnhancedAA         : Integer  ;
    { Added for version 4:
        1=enabled, 0=disabled }
    AdaptiveSampling   : Integer  ;
    { Added for version 4:
        Only valid when adaptiveSampling is enabled }
    AdaptiveThreshold  : Single   ;
    { Added for version 4:
        bit 0: 1=soft filter, 0=no filter
      Added 12/29/2004:
        bits 1thru5 indicate reconstruction filter.
              1-3   = box(std,sharp,soft)     ;
              4-6   = Gaussian(std,sharp,soft);
              7-9   = Mitchell(std,sharp,soft);
              10-12 = Lanczos(std,sharp,soft) ; }
    Filter             : Integer  ;
    DblSidedAreaLights : Integer  ;
    { Added for version 5:
        0 = no scene loading;
        1 = scene load is in progress;
        2 = load-from-scene in progress }
    LoadInProgress               : Integer  ;
    RadiosityType                : Integer  ;
    RadiosityIndirectBounceCount : Integer  ;
    RadiosityRaysPerEvaluation1  : Integer  ;
    RadiosityRaysPerEvaluation2  : Integer  ;
    RadiosityIntensity                      ,
    RadiosityAngularTolerance               ,
    RadiosityMinimumPixelSpacing            ,
    RadiosityMaximumPixelSpacing            ,
    RadiosityMultiplier          : Double   ;
    RadiosityFileName            : Pchar    ; // const
    { Added for LW9.6 }
    CausticsIntensity            : Double   ;
    CausticsAccuracy                        ,
    CausticsSoftness                        ,
    RadiosityFlags               : Integer  ;
    DynamicsRangeMin                        ,
    DynamicsRangeMax                        ,
    Saturation                   : Double   ;

    PixelFilterForceMT                      ,
    { All active pixel filters are capable of multi-threading. }
    HasMultithreadedFilters                 ,
    UseZminmax                   : Integer  ;
    Zmin                                    ,
    Zmax                         : Double   ;
    { LWRENDERINGMODE enum.}
    Rendermode                              ,
    { Forces the calculation of normals, in layout or while rendering. }
    CalculateAllNormals          : Integer  ;
    { Added for LW9.7 }
    EnableLenseFlares            : Integer  ;
    LenseFlareIntensity          : Double   ;
    { Added for LW10.1 *}
    { Pointer to the flags array of the buffers currently in use. }
    BuffersInUse                 : PInteger ;
    { Current phase of animation calculation (LWANIMPASS_). }
    AnimationPass                : Integer  ;

    { Added for LW11 }
    RayCutoff                    : Single   ;
    Shadingsamples                          ,
    Lightsamples                 : UInt32   ;

  end;

  PLWTimeInfo = ^TLWTimeInfo;
  TLWTimeInfo = record
    Time    : TLWTime  ;
    Frame   : TLWFrame ;
  end;

  PLWCompInfo = ^TLWCompInfo;
  TLWCompInfo = record
    BG         ,
    FG         ,
    FGAlpha    : PLWImage;
  end;

  PLWBackdropInfo = ^TLWBackdropInfo;
  TLWBackdropInfo  = record
    Backdrop : procedure
               (      Time   : TLWTime               ;
                const Ray    : array {[0..2]} of Double ;
                      Color  : array {[0..2]} of Double ) ;
    Type_    : Integer                               ;
    Color    : procedure
               (      Time   : TLWTime               ;
                      Zenith                         ,
                      Sky                            ,
                      Ground                         ,
                      Nadir  : array {[0..2]} of Double ) ;
    Squeeze  : procedure
               (      Time   : TLWTime               ;
                      Sky                            ,
                      Ground : PDouble               );
  end;

  PLWFogInfo = ^TLWFogInfo;
  TLWFogInfo = record
      Type_   : Integer      ;
      Flags   : UInt32  ;
      MinDist : function
                (      Time   : TLWTime                  ) : Double;
      MaxDist : function
                (      Time   : TLWTime                  ) : Double;
      MinAmt  : function
                (      Time   : TLWTime                  ) : Double;
      MaxAmt  : function
                (      Time   : TLWTime                  ) : Double;
      Color   : procedure
                (      Time   : TLWTime                  ;
                       Col    : array {[0..2]} of Double ) ;
  end;

  PLWInterfaceInfo = ^TLWInterfaceInfo;
  TLWInterfaceInfo = record
    CurTime              : TLWTime ;
    SelItems             : PLWItem ;

    ItemFlags            : function
                           (      Item  : PLWItem    ) : Uint32 ;
    PreviewStart         ,
    PreviewEnd           ,
    PreviewStep          : TLWFrame;

    DynaUpdate           : Integer ;

    SchemaPos            : procedure
                           (      Item  : PLWItem    ;
                                  X     ,
                                  Y     : PDouble    ) ;
    ItemVis              : function
                           (      Item  : PLWItem    ) : Integer;

    DisplayFlags         ,
    GeneralFlags         : Uint32  ;
    BoxThreshold         : Integer ;

    ItemColor            : function
                           (      Item  : PLWItem    ) : Integer;
    SetItemColorIndex    : procedure
                           (      Item  : PLWItem    ;
                                  Color : Integer    ) ;
    SetItemColorCustom   : procedure
                           (      Item  : PLWItem    ;
                                  Color : PDouble    ) ;

    AlertLevel                     ,
    AutoKeyCreate        : Integer ;

    DefaultItemTypeColor : procedure
                           (      Item  : PLWItem    ;
                                  Color : PSingle    ;
                                  Set_  : Integer    ) ;
    ItemColorRGBA        : procedure
                           (      Item  : PLWItem    ;
                                  State : UInt32     ;
                                  RGBA  : TLWFVector4) ;
    ItemIconScale        : function
                           (      Item  : PLWItem    ) : Single ;
  end;

  PLWViewportInfo = ^TLWViewportInfo;
  TLWViewportInfo = record
    NumViewports : Integer;

    Type_        : function
                   (      Index         : Integer                 ) : Integer;
    Flags        : function
                   (      Index         : Integer                 ) : UInt32 ;
    Pos          : procedure
                   (      Index         : Integer                 ;
                          Spot          : TLWDVector              ) ;
    Xfrm         : procedure
                   (      Index         : Integer                 ;
                          Mat           : Array {[0..8]} of Double) ;
    Clip         : procedure
                   (      Index         : Integer                 ;
                          Hither        ,
                          Yon           : PDouble                 ) ;
    Rect         : procedure
                   (      Index         : Integer                 ;
                          Left, Top     ,
                          Width, Height : PInteger                ) ;
    ViewLevel    : function
                   (      Index         : Integer                 ) : Integer;
    Projection   : function
                   (      Index         : Integer                 ;
                          Projection    ,
                          InvProjection : TLWDMatrix4             ) : Integer;
    Modelview    : function
                   (      Index         : Integer                 ;
                          Modelview     ,
                          InvModelView  : TLWDMatrix4             ) : Integer;
    Project      : function
                   (      Index         : Integer                 ;
                          World         : TLWDVector              ;
                          WinX          ,
                          WinY          ,
                          WinZ          : PDouble                 ) : Integer;
    UnProject    : function
                   (      Index         : Integer                 ;
                          WinX          ,
                          WinY          ,
                          WinZ          : Double                  ;
                          World         : TLWDVector              ) : Integer;
    PixelSize    : function
                   (      Index         : Integer                 ;
                          Pixels        : Double                  ;
                          RefPos        : TLWDVector              ) : Double ;
    HandleSize   : function
                   (      Index         : Integer                 ) : Integer;
    GridSize     : function
                   (      Index         : Integer                 ) : Double ;
    ViewItem     : function
                   (      Index         : Integer                 ) : PLWItem;
    GridType     : function
                   (      Index         : Integer                 ) : Integer;
  end;

  PLWMemChunk = Pointer;

  PLWGlobalPool = ^TLWGlobalPool;
  TLWGlobalPool = record
      First     : function
                  ( const Void                   ) : PLWMemChunk ;
      Next      : function
                  (       MemChunk : PLWMemChunk ) : PLWMemChunk ;
      ID        : function
                  (       MemChunk : PLWMemChunk ) : PChar       ; // const
      Size      : function
                  (       MemChunk : PLWMemChunk ) : Integer     ;
      Find      : function
                  ( const InID     : PChar       ) : PLWMemChunk ;
      Create    : function
                  ( const InID     : PChar       ;
                          InSize   : Integer     ) : PLWMemChunk ;
  end;

implementation

end.
